package com.fms.mdmservice.controller;

import com.fms.commons.controller.BaseController;
import com.fms.commons.service.IBaseService;
import com.fms.commons.domain.PageData;
import com.fms.mdmservice.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("mdm")
public class UserController extends BaseController {

    private final Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserService userService;

    @Override
    public IBaseService getService(){
        return userService;
    }

    @RequestMapping(value="/user/{userId}", method=RequestMethod.GET)
    public PageData findUser(@PathVariable String userId){
        return super.findById(userId);
    }

    @RequestMapping(value="/user", method=RequestMethod.GET)
    public PageData findUser(@RequestParam Map<String, String> map){
        return super.findList(map);
    }

    @RequestMapping(value="/user", method=RequestMethod.POST)
    public PageData addUser(@RequestBody PageData param){
        return super.add(param);
    }

    @RequestMapping(value="/user/{id}", method=RequestMethod.PUT)
    public PageData editUser(@PathVariable String id, @RequestBody PageData param){
        return super.edit(id, param);
    }

    @RequestMapping(value="/user/{id}", method=RequestMethod.DELETE)
    public PageData deleteUser(@PathVariable String id){
        return super.delete(id);
    }

}
